﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace C_onsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //ToolMan toolman = new ToolMan("班长");

            //LazyMan lazyMan1 = new LazyMan("学委");
            //LazyMan lazyMan2 = new LazyMan("张三");
            //LazyMan lazyMan3 = new LazyMan("李四");

            //toolman.DownStair += lazyMan1.TakeFood;
            //toolman.DownStair += lazyMan2.TakeFood;
            //toolman.DownStair += lazyMan3.TakeFood;
            //toolman.DownStair += lazyMan2.TakeFood;
            //toolman.DownStair += lazyMan2.TakeFood;

            //toolman.Print();

            //string pattern = @"^\d+$";
            //string pattern1 = @"^\d{1,}$";
            //string pattern2 = @"^\d{5,6}$";
            //string pattern3 = @"^\d{5}$";
            //while (true)
            //{
            //    string input = Console.ReadLine();
            //    Console.WriteLine(Regex.IsMatch(input, pattern));
            //}

            //string pattern = @"^(13|15|18)\d{9}$";
            //while (true)
            //{
            //    string input = Console.ReadLine();
            //    Console.WriteLine(Regex.IsMatch(input, pattern));
            //}
            //string str = "今天是2025-09-22, 我们在上课";
            //string pattern = @"(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})";
            //Match match = Regex.Match(str, pattern);
            //if (match.Success)
            //{
            //    Console.WriteLine(match.Groups["year"].Value);
            //    Console.WriteLine(match.Groups["month"].Value);
            //    Console.WriteLine(match.Groups["day"].Value);
            //}

            //string input = "Hello,正则表达式。";
            //string result = Regex.Replace(input, @"\w", "*");//所有字符改成*
            //Console.WriteLine(result);
            //string input2 = "Hello 正则表达式。";
            //string result2 = Regex.Replace(input2, @"\s+"," ");//多个空格/制表符改成一个空*
            //Console.WriteLine(result2);

            //ThreeHole threehole = new Adapter();
            //threehole.Request();

            //RemotrControl remote = new ConcreateRemote1();

            //remote.Tv = new ChangHong();
            //remote.On();
            //remote.NextChannel();
            //remote.Off();
            //Console.WriteLine();

            //remote = new ConcreateRemote2();
            //remote.Tv = new Sanxing();
            //remote.On();
            //remote.NextChannel();
            //remote.Off();

            //Facade facade = new Facade();
            //facade.RegisterCourse("张三", "设计模式1");
            //facade.RegisterCourse("李四", "设计模式2");

            //Graphics graphics = new ComplexGraphics("两个线程和一个复合图形");

            //Line l = new Line("线程A");
            //graphics.Add(l);

            //graphics.Add(new Line("线程B"));

            //ComplexGraphics complex = new ComplexGraphics("一个线程和一个圆");
            //complex.Add(new Line("线程A"));
            //complex.Add(new Crile("圆A"));
            //graphics.Add(complex);


            //graphics.Draw();

            //graphics.Remove(l);
            //graphics.Draw();

            Decorator decorator = null;
            Phone phone = new ApplePhone();

            decorator = new Sticker(phone);
            decorator.Print();
            decorator = new Accessories(decorator);
            decorator.Print();
        }
    }

    abstract class Phone
    {
        public abstract void Print();
    }

    class ApplePhone : Phone
    {
        public override void Print()
        {
            Console.WriteLine("开始执行手机主体的装饰");
        }
    }

    abstract class Decorator : Phone
    {
        private Phone phone;
        public Decorator(Phone phone)
        {
            this.phone = phone;
        }
        public override void Print() { 
        phone.Print();
        }
    }

    class Sticker : Decorator
    {
        public Sticker(Phone phone) : base(phone)
        {
        }

        public override void Print()
        {
            base.Print();
            AddSticker();
        }

        public void AddSticker()
        {
            Console.WriteLine("增加贴膜的职责");
        }
    }
    
    class Accessories : Decorator
    {
        public Accessories(Phone phone) : base(phone)
        { }

        public override void Print()
        {
            base.Print();
            AddAcessories();
        }

        public void AddAcessories()
        {
            Console.WriteLine("增加挂件的职责");
        }
    }
    //abstract class Graphics
    //{
    //    private string name;

    //    public string Name { get =>  name; set => name = value; }

    //    public Graphics(string name) { 
    //    Name = name;
    //    }

    //    public abstract void Draw();

    //    public abstract void Add(Graphics graphics);

    //    public abstract void Remove(Graphics graphics);
    //}

    //class Line : Graphics
    //{
    //    public Line(string name) : base(name)
    //    {
    //    }

    //    public override void Add(Graphics graphics)
    //    {
    //        Console.WriteLine("不需要添加图形");
    //    }
    //    public override void Draw()
    //    {
    //        Console.WriteLine("绘制一个线程" + Name);
    //    }

    //    public override void Remove(Graphics graphics)
    //    {
    //        Console.WriteLine("不需要移除图形");
    //    }
    //}

    //class Crile : Graphics
    //{
    //    public Crile(string name) : base(name)
    //    {
    //    }

    //    public override void Add(Graphics graphics)
    //    {
    //        Console.WriteLine("不需要添加图形");
    //    }
    //    public override void Draw()
    //    {
    //        Console.WriteLine("绘制一个圆" + Name);
    //    }

    //    public override void Remove(Graphics graphics)
    //    {
    //        Console.WriteLine("不需要移除图形");
    //    }
    //}

    //class ComplexGraphics : Graphics
    //{

    //    List<Graphics> graphicsList = new List<Graphics>();
    //    public ComplexGraphics(string name) : base(name)
    //    {
    //    }

    //    public override void Add(Graphics graphics)
    //    {
    //        graphicsList.Add(graphics);
    //    }
    //    public override void Draw()
    //    {
    //        foreach (Graphics graphics in graphicsList)
    //        {
    //            graphics.Draw();
    //        }
    //    }

    //    public override void Remove(Graphics graphics)
    //    {
    //        graphicsList.Remove(graphics);
    //    }
    //}

}
